<?
#####################################################
#  COPYRIGHT NOTICE
#####################################################
# In the following statements, the term "this 
# program" refers to all files associated with the
# execution and distribution of Adtrackz.
#
# This Program is Copyright 2004 Jonah Klimack.
# All Rights Reserved. 
#
# Selling the code for this program, modifying 
# and/or redistributing the code for this program
# in part or in whole over the Internet or in any 
# other medium is expressly forbidden. Violators
# will be prosecuted to the fullest extent of the law
# Copyright and header information may not be
# modified.
#
# This program is distributed "as is" and without 
# warranty of any kind, either express or implied.
# In no event shall the liability of Jonah Klimack 
# for any damages, losses and/or causes of 
# action exceed the total amount paid by the 
# user for this software.		
#####################################################
# DO NOT MODIFY ANYTHING IN THIS FILE
#####################################################

if ($submit)
{
	if(!$new_username)
	{
		do_header();
		error("You must enter a username.");
	}
	elseif(!$new_password)
	{
		do_header();
		error("You must enter a password.");
	}
	elseif(strlen($new_password) < 3 || strlen($new_password) > 12)
	{
		do_header();
		error("Password must be between 3 and 12 characters.");
	}
	elseif(!$email)
	{
		do_header();
		error("You must enter an email address.");
	}
	elseif(!$ftp_user)
	{
		do_header();
		error("You must enter a FTP username.");
	}
	elseif(!$ftp_pass)
	{
		do_header();
		error("You must enter a FTP password.");
	}
	elseif(!$default_url)
	{
		do_header();
		error("You must enter a default url.");
	}
	else
	{
		$cvalue = "$new_username|$new_password";
		$cookie = setcookie("adtrackz",$cvalue);
		$cookie = setcookie("adtrackz_remember",$cvalue,mktime (0,0,0,12,32,2010));

		require "header.php";

		echo "<p class=small align=left>Help > Update Profile</p><p class=heading>Edit Your Profile</p><p>To make changes to your profile edit the fields below and click save changes.</p>";

		mysql_query("update adtrackz_login set username='$new_username', password='$new_password', email='$email', ftp_pass='$ftp_pass', ftp_user='$ftp_user', default_url='$default_url'");

		alert("Your profile has been updated");
	}
}
else
{
	//load up values
	require "header.php";

	echo "<p class=small align=left>Help > Update Profile</p><p class=heading>Edit Your Profile</p><p>To make changes to your profile edit the fields below and click save changes.</p>";

	list ($username, $password, $email, $ftp_user, $ftp_pass, $default_url) = mysql_fetch_row(mysql_query("select username, password, email, ftp_user, ftp_pass, default_url from adtrackz_login"));
	$new_username = $username;
	$new_password = $password;
}
?>
<form action="profile.php" method="post">
<table width="500" border="0" cellspacing="0" cellpadding="5" align="center" bgcolor="white"  bordercolor="white">
<tr>
	<td valign="top">Your AdTrackzGold Username</td>
	<td valign="top">
		<input type="text" size="20" name="new_username" value="<?=$new_username?>"> 		
	</td>
</tr>
<tr>
	<td valign="top">Your AdTrackzGold Password</td>
	<td valign="top">
		<input type="text" size="20"  name="new_password" value="<?=$new_password?>"> 		
	</td>
</tr>
<tr>
	<td valign="top">Your Email Address</td>
	<td valign="top">
		<input type="text" size="20" name="email" value="<?=$email?>"> 		
	</td>
</tr>
<tr>
	<td>&nbsp;</td>
	<td><span class=small>
	If you forget your username and password, you can have it resent to this
	email address.</span>
	</td>
</tr>
<tr>
	<td valign="top">Your FTP Username</td>
	<td valign="top">
		<input type="text" size="20"  name="ftp_user" value="<?=$ftp_user?>"> 		
	</td>
</tr>
<tr>
	<td valign="top">Your FTP Password</td>
	<td valign="top">
		<input type="text" size="20"  name="ftp_pass" value="<?=$ftp_pass?>"> 		
	</td>
</tr>
<tr>
	<td valign="top">Your Default Url</td>
	<td valign="top">
		<input type="text" size="25" name="default_url" value="<?=$default_url?>"> 		
	</td>
</tr>
<tr>
<td colspan=2 align=center>&nbsp;
	
</td>
</tr>
<tr>
<td colspan=2 align=center>
	<input type=submit value="Save Changes" name="submit"  >
</td>
</table>
</form>
<?

function do_header()
{
	require "header.php";

	echo "<p class=small align=left>Help > Update Profile</p><p class=heading>Edit Your Profile</p><p>To make changes to your profile edit the fields below and click save changes.</p>";
}

require "footer.php";

?>